home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DDJMAG / DDJ9310.ZIP / DFPP03.ZIP / DIRECTRY.CPP < prev    next >
C/C++ Source or Header  |  1993-09-23  |  3KB  |  106 lines

  1. // ---------- directry.cpp
  2.  
  3. #include <direct.h>
  4. #include "directry.h"
  5.  
  6. const char *PathNameLabel::CurrentPath()
  7. {
  8.     static char path[129];
  9.     _getdcwd(0, path, 129);
  10.     return path;
  11. }
  12.  
  13. void PathNameLabel::FillLabel()
  14. {
  15.     SetText(CurrentPath());
  16. }
  17.  
  18.  
  19. DriveListBox::DriveListBox(int lf, int tp, DFWindow *par)
  20.                         : ListBox(lf, tp, 10, 10, par)
  21. {
  22.     SetAttribute(BORDER);
  23.     currdrive = getdisk();
  24.     union REGS regs;
  25.     for (unsigned int dr = 0; dr < 26; dr++)    {
  26.         setdisk(dr);
  27.         if (getdisk() == dr)    {
  28.             // ----- test for remapped B drive
  29.             if (dr == 1)    {
  30.                 regs.x.ax = 0x440e; // IOCTL func 14
  31.                 regs.h.bl = dr+1;
  32.                 int86(0x21, ®s, ®s);
  33.                 if (regs.h.al != 0)
  34.                     continue;
  35.             }
  36.             
  37.             String drname(" :");
  38.             drname[0] = dr+'A';
  39.  
  40.             // ---- test for network or RAM disk
  41.             regs.x.ax = 0x4409;     // IOCTL func 9
  42.             regs.h.bl = dr+1;
  43.             int86(0x21, ®s, ®s);
  44.             if (!regs.x.cflag)    {
  45.                 if (regs.x.dx & 0x1000)
  46.                     drname += " (Net)";
  47.                 else if (regs.x.dx == 0x0800)
  48.                     drname += " (RAM)";
  49.             }
  50.             AddText(drname);
  51.         }
  52.     }
  53.     setdisk(currdrive);
  54.     SetScrollBars();
  55. }
  56.  
  57.  
  58. DirectoryListBox::DirectoryListBox(int lf, int tp, DFWindow *par)
  59.                         : ListBox(lf, tp, 10, 13, par)
  60. {
  61.     SetAttribute(BORDER);
  62.     FillList();
  63. }
  64.  
  65. void DirectoryListBox::FillList()
  66. {
  67.     ClearText();
  68.     int ax;
  69.     struct ffblk ff;
  70.     ax = findfirst("*.*", &ff, FA_DIREC);
  71.     while (ax == 0)    {
  72.         if ((ff.ff_attrib & FA_DIREC) != 0)    {
  73.             if (strcmp(ff.ff_name, "."))    {
  74.                 String fname("[");
  75.                 fname += ff.ff_name;
  76.                 fname += "]";
  77.                 AddText(fname);
  78.             }
  79.         }
  80.         ax = findnext(&ff);
  81.     }
  82.     SetScrollBars();
  83. }
  84.  
  85. FileNameListBox::FileNameListBox(const char *filespec,int lf,int tp, DFWindow *par)
  86.                         : ListBox(lf, tp, 10, 14, par)
  87. {
  88.     SetAttribute(BORDER);
  89.     FillList(filespec);
  90. }
  91.  
  92. void FileNameListBox::FillList(const char *filespec)
  93. {
  94.     ClearText();
  95.     int ax;
  96.     struct ffblk ff;
  97.     ax = findfirst(*filespec ? filespec : "*.*", &ff, 0);
  98.     while (ax == 0)    {
  99.         AddText(ff.ff_name);
  100.         ax = findnext(&ff);
  101.     }
  102.     SetScrollBars();
  103. }
  104.  
  105.  
  106.